package dreamCookGame;

import java.awt.image.BufferedImage;

public class CharacterBehavior {
	
	public String _behaviorName;
	BufferedImage[] _frames;
	BufferedImage _currentFrame;
	public int _frameIndex;
	String _behaviorFramesImgsName;
	public boolean _isUserControlled;
	
	public CharacterBehavior(String behaviorName, boolean isUserControlled, int numOfFrames, String behaviorFramesImgsName) {
		_behaviorName = behaviorName;
		_isUserControlled = isUserControlled;
		_behaviorFramesImgsName = behaviorFramesImgsName;
		_frames = new BufferedImage[numOfFrames];
		_frameIndex = 0;
		
	}
	
	public void loadResources(References reference) {
		_frames  = reference.getImageArray(_behaviorFramesImgsName);
		_currentFrame = _frames[_frameIndex];
	}
	
	public BufferedImage getCurrentFrame() {
		return _frames[_frameIndex];
	}
	
	public void setToNextFrame() {
		if(_frameIndex + 1 == _frames.length)
			_frameIndex = 0;
		else
			_frameIndex++;
		
		_currentFrame = _frames[_frameIndex];		
	}
	
}
